package com.zy.chat.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zy.chat.entity.Friend;
import com.zy.chat.mapper.FridendMapper;
import com.zy.chat.service.FriendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class FriendServiceImpl extends ServiceImpl<FridendMapper, Friend> implements FriendService {

    @Autowired
    private FridendMapper fridendMapper;

    @Override
    public boolean ifFriend(int userId, int friendId) {
        QueryWrapper<Friend> friendQueryWrapper = new QueryWrapper<>();
        friendQueryWrapper.eq("user_id",userId).eq("friend_id",friendId);
        Friend friend= this.fridendMapper.selectOne(friendQueryWrapper);
        if(friend!=null){
            return true;
        }else {
            return false;
        }
    }
}
